//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package io.gitee.caoxiaoyu97.util;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

public class PathUtil {
    public PathUtil() {
    }

    public static String getJavaPath(String name, String outDir) {
        name = name.replaceAll("\\.", "/");
        return outDir + "/" + name + ".java";
    }

    public static String getJavaClassPath(String name, String outDir) {
        name = name.replaceAll("\\.", "/");
        return outDir + "/" + name + ".class";
    }

    public static String getJavaSrc(String name, String outDir) {
        name = name.replaceAll("\\.", "/");
        return outDir + "/" + name;
    }

    public static URL[] getURLS(String... jars) throws MalformedURLException {
        URL[] urls = new URL[jars.length];

        for(int i = jars.length - 1; i >= 0; --i) {
            URL url = new URL(buildUrl(jars[i]));
            urls[i] = url;
        }

        return urls;
    }

    public static URL[] getURLS(List<String> jars) throws MalformedURLException {
        URL[] urls = new URL[jars.size()];

        for(int i = jars.size() - 1; i >= 0; --i) {
            URL url = new URL(buildUrl((String)jars.get(i)));
            urls[i] = url;
        }

        return urls;
    }

    public static String buildUrl(String path) {
        path = "file:" + path;
        return path;
    }
}
